<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ManageSystem管理系统</title> 
    <!-- bootstrap 3.0.2 -->
    <link href="/resource/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="/resource/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="/resource/css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Morris chart -->
    <link href="/resource/css/morris/morris.css" rel="stylesheet" type="text/css" />
    <!-- jvectormap -->
    <link href="/resource/css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
    <!-- iCheck for checkboxes and radio inputs -->
    <link href="/resource/css/iCheck/all.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="/resource/css/style.css" rel="stylesheet" type="text/css" />
	<style>
		.pwsd{
			position: absolute;
			left: 0px;
			margin-top: -490px;
			margin-left: 200px;
			z-index: 1200;
			width: 900px;
			height: 550px;
			background-color: #00a7d0;
			box-shadow: #bab6aa;
			display: none;
			border-bottom-left-radius: 10px;
			border-bottom-right-radius: 10px;
			border-top-left-radius: 36px;
			border-top-right-radius: 10px;
		}
		.fugai{
			width: 1000%;
			height: 650px;
			position: absolute;
			left: auto;
			margin-top: -505px;
			z-index: 1100;
			background-color: rgba(41, 81, 62, 0.92);
			display: none;
		}


		.container {
			position: absolute;
			/*margin: auto;*/
			top: 0;
			/*left: 0;*/
			right: 100px;
			bottom: 0;
			width: 150px;
			height: 50px;
		}
		.container .search {
			position: absolute;
			margin: auto;
			top: 8px;
			right: 0;
			bottom: 0;
			left: 0;
			width: 50px;
			height: 50px;
			background: crimson;
			border-radius: 50%;
			transition: all 1s;
			z-index: 4;
			box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
		}
		.container .search:hover {
			cursor: pointer;
		}
		.container .search::before {
			content: "";
			position: absolute;
			margin: auto;
			top: 22px;
			right: 0;
			bottom: 0;
			left: 22px;
			width: 12px;
			height: 2px;
			background: white;
			transform: rotate(45deg);
			transition: all .5s;
		}
		.container .search::after {
			content: "";
			position: absolute;
			margin: auto;
			top: -5px;
			right: 0;
			bottom: 0;
			left: -5px;
			width: 25px;
			height: 25px;
			border-radius: 50%;
			border: 2px solid white;
			transition: all .5s;
		}
		.container input {
			font-family: 'Inconsolata', monospace;
			position: absolute;
			margin: auto;
			top: 0;
			/*right: 0;*/
			bottom: 0;
			/*left: 0;*/
			width: 50px;
			height: 50px;
			outline: none;
			border: none;
			background: crimson;
			color: white;
			text-shadow: 0 0 10px crimson;
			padding: 0 80px 0 20px;
			border-radius: 30px;
			box-shadow: 0 0 25px 0 crimson, 0 20px 25px 0 rgba(0, 0, 0, 0.2);
			transition: all 1s;
			opacity: 0;
			z-index: 5;
			font-weight: bolder;
			letter-spacing: 0.1em;
		}
		.container input:hover {
			cursor: pointer;
		}
		.container input:focus {
			width: 300px;
			opacity: 1;
			cursor: text;
		}
		.container input:focus ~ .search {
			right: -250px;
			background: #151515;
			z-index: 6;
		}
		.container input:focus ~ .search::before {
			top: 0;
			left: 0;
			width: 25px;
		}
		.container input:focus ~ .search::after {
			top: 0;
			left: 0;
			width: 25px;
			height: 2px;
			border: none;
			background: white;
			border-radius: 0%;
			transform: rotate(-45deg);
		}
		.container input::placeholder {
			color: white;
			opacity: 0.5;
			font-weight: bolder;
		}
	</style>
</head>

<body>
	<div class="row">
	    <div class="col-md-12">
	    	<h1 class="panel-heading">学生成绩</h1>
	        <!--breadcrumbs start -->
	        <ul class="breadcrumb">
				<li><a href="/index/toIndex"><i class="fa fa-home"></i> 首页</a></li>
				<li class="active">学生成绩</li>
			</ul>
	        <!--breadcrumbs end -->
	    </div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<section class="panel">
				<div class="panel-body">
					<!-- <span class="pull-right badge badge-info">32</span> -->
					<button class="btn btn-primary btn-addon btn-sm" th:onclick="saveScore();">
						<i class="fa fa-plus"></i>新增学生成绩
					</button>
					<div class="container">
						<input id="searchStuScore"  type="text" placeholder="请输入学号...">
						<div class="search"></div>
					</div>
				</div>
			    <div class="panel-body table-responsive">
					<table class="table table-hover">
						<thead>
							<tr>
								<th style="width:50px;">序号</th>
								<th>班级名称</th>
								<th>学号</th>
								<th>姓名</th>
								<th>Java</th>
								<th>C++</th>
								<th>Mysql</th>
								<th>高数</th>
								<th>化学</th>
								<th>生物</th>
								<th>历史</th>
								<th>总分</th>
								<th style="width:150px;">操作</th>
							</tr>
						</thead>
						<tbody>
							<tr th:each="item,stat : ${scoreDTOs.list}">
								<td><input type="checkbox" class="flat-grey list-child" th:value="${item.stuNumber}" /> </td>
								<td th:text="${item.className}"></td>
								<td th:text="${item.stuNumber}"></td>
								<td th:text="${item.stuName}"></td>
								<td th:text="${item.javaScore}"></td>
								<td th:text="${item.cPlusScore}"></td>
								<td th:text="${item.mysqlScore}"></td>
								<td th:text="${item.mathScore}"></td>
								<td th:text="${item.chemistryScore}"></td>
								<td th:text="${item.biologyScore}"></td>
								<td th:text="${item.historyScore}"></td>
								<td th:text="${item.sumScore}"></td>
								<td>
									<!--<a th:href="@{/stu/student/toEdit(id=${item.stuNumber})}" class="btn btn-xs btn-success">编辑</a>-->
									<button onclick="editScore(this.value);" th:value="${item.stuNumber}" class="btn btn-xs btn-success">编辑</button>
									<span>&nbsp;|&nbsp;</span>
									<a href="javascript:void(0)" data-toggle="modal" class="btn btn-xs btn-danger" th:itemid="${item.stuNumber}" th:onclick="confrimRemove(this.getAttribute('itemid'));">删除</a>
								</td>
							</tr>
							<tr th:if="${#lists.isEmpty(scoreDTOs.list)}">
								<td colspan="9" align="center">无数据</td>
							</tr>
						</tbody>
					</table>
			    </div>
			    <div class="panel-footer bg-white text-right">
                     <ul class="pagination">
                         <li><a th:href="@{/stu/score/teachList(pageNum=${scoreDTOs.navigateFirstPage},pageSize=${scoreDTOs.pageSize})}" title="首页" th:class="${scoreDTOs.isFirstPage} ? 'paginationNotAllowed' : ''">«</a></li>
                         <li><a th:href="@{/stu/score/teachList(pageNum=${scoreDTOs.prePage},pageSize=${scoreDTOs.pageSize})}" title="上一页" th:if="${scoreDTOs.hasPreviousPage}">‹</a></li>
                         <li th:each="pageinfo : ${scoreDTOs.navigatepageNums}"><a th:href="@{/stu/score/teachList(pageNum=${pageinfo},pageSize=${scoreDTOs.pageSize})}" th:class="${pageinfo == scoreDTOs.pageNum} ? 'paginationActive' : ''" th:text="${pageinfo}"></a></li>
                         <li><a th:href="@{/stu/score/teachList(pageNum=${scoreDTOs.nextPage},pageSize=${scoreDTOs.pageSize})}" title="下一页" th:if="${scoreDTOs.hasNextPage}">›</a></li>
                         <li><a th:href="@{/stu/score/teachList(pageNum=${scoreDTOs.navigateLastPage},pageSize=${scoreDTOs.pageSize})}" title="未页" th:class="${scoreDTOs.isLastPage} ? 'paginationNotAllowed' : ''">»</a></li>
                     </ul>
                 </div>
			</section>
		</div>
	</div>
	<!--删除提示框-->
	<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="remove-dialog" class="modal fade">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
					<h4 class="modal-title">操作提示？</h4>
				</div>
				<div class="modal-body">
					<h4 class="modal-title">您确定要删除该记录吗？</h4>
					<input type="hidden" id="cacheID" />
					<!-- <input type="hidden" id="cid" /> -->
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-primary btn-addon btn-sm" onclick="remove();">确定</button>
					<button type="button" class="btn btn-default btn-sm" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>


	<!--弹框新增成绩弹框-->
	<div id="pwsd" class="pwsd">
		<div class="pws">
			<div class="panel-body">
				<h2><i class="fa fa-lock"></i>  新增学生成绩</h2>
				<hr>
				<div class="form-horizontal" data-validator-form>
					<form enctype="multipart/form-data" method="post" th:action="@{/stu/score/add}" onsubmit="return validateForm();">
						<input type="hidden"  id="saveOrEdit" name="saveOrEdit" value="1"/>
						<div class="form-group">
							<label class="col-sm-2 control-label">学号</label>
							<div class="col-sm-3">
								<input id="stuNumber" name="stuNumber"  type="number" class="form-control"   placeholder="请输入正确的学号信息">
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">Java</label>
							<div class="col-sm-3">
								<input id="javaScore"  name="javaScore"  type="number" min="0" max="100" class="form-control"  placeholder="Java分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >C++</label>
							<div class="col-sm-3">
								<input id="cPlusScore" name="cPlusScore" type="number" min="0" max="100" class="form-control" placeholder="C++分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >Mysql</label>
							<div class="col-sm-3">
								<input id="mysqlScore" name="mysqlScore" type="number" min="0" max="100" class="form-control" placeholder="Mysql分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >高数</label>
							<div class="col-sm-3">
								<input id="mathScore" name="mathScore" type="number" min="0" max="100" class="form-control" placeholder="高数分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >化学</label>
							<div class="col-sm-3">
								<input id="chemistryScore" name="chemistryScore" type="number" min="0" max="100" class="form-control" placeholder="化学分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >生物</label>
							<div class="col-sm-3">
								<input id="biologyScore" name="biologyScore" type="number" min="0" max="100" class="form-control" placeholder="生物分数0-100">
							</div>
						</div>
						<div class="form-group">
							<label  class="col-sm-2 control-label" >历史</label>
							<div class="col-sm-3">
								<input id="historyScore" name="historyScore" type="number" min="0" max="100" class="form-control" placeholder="历史分数0-100">
							</div>
						</div>

						<input id="createdBy" name="createdBy" type="hidden" class="form-control" />
						<input id="updatedBy" name="updatedBy" type="hidden" class="form-control" />
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-6">
								<button type="submit" class="btn btn-primary" >确认提交</button>
								<button type="button" class="btn btn-primary" onclick="colseWin();">确认退出</button>
							</div>
						</div>
					</form>
					<div class="checkbox icheck">
						<label class=""></label>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!--页面遮挡侧面-->
	<div id="fugai" class="fugai">


	</div>
	<!-- jQuery 2.0.2 -->
	<script src="/resource/js/jquery.min.js" type="text/javascript"></script>
	<!-- jQuery UI 1.10.3 -->
	<script src="/resource/js/jquery-ui-1.10.3.min.js" type="text/javascript"></script>
	<!-- Bootstrap -->
	<script src="/resource/js/bootstrap.min.js" type="text/javascript"></script>
	<!-- iCheck -->
    <script src="/resource/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>
	<!-- Director App -->
	<script src="/resource/js/Director/app.js" type="text/javascript"></script>
	<script src="/resource/js/jquery.serializejson.js"></script>
	<script type="text/javascript">

		//获取当前登录的用户--防止菜单被拖出去访问
		var scoreStuStr = sessionStorage.getItem("douglas");
		if(scoreStuStr == null || scoreStuStr == "" || scoreStuStr == "undefined"){
			window.location.href = "/admin/toLogin";
		}else{
			var user = JSON.parse(scoreStuStr);
			$("#createdBy").val(user.realname);
		}

		//新增弹框  th:onclick="editPassword();"
		function saveScore() {
			document.getElementById("pwsd").style.cssText="display:block";
			document.getElementById("fugai").style.cssText="display:block";
		}
		//关闭新增弹框
		function colseWin() {
			document.getElementById("pwsd").style.cssText="display:none";
			document.getElementById("fugai").style.cssText="display:none";
			window.location.href="/stu/score/teachList";
		}

		//搜索回车事件
		$('#searchStuScore').bind('keydown',function(event){
			if(event.keyCode == "13") {
				var stuNumber = $("#searchStuScore").val();
				// alert(stuNumber);
				window.location.href="/stu/score/teachList?stuNumber="+stuNumber;
			}
		});

		//编辑弹框
		function editScore(stuNumber) {
			//获取id
			console.log(stuNumber);
			//发送ajax请求获取详细信息
			getScoreByStuNumber(stuNumber);
			// 设置更新人
			var user = JSON.parse(scoreStuStr);
			$("#updatedBy").val(user.realname);
			document.getElementById("pwsd").style.cssText="display:block";
			document.getElementById("fugai").style.cssText="display:block";
		}

		//根据id查询Lesson对象的请求
		function getScoreByStuNumber(stuNumber){
			$.ajax({
				url : "/stu/score/getScore?stuNumber="+stuNumber,
				contentType : 'application/json',
				type : "GET",
				dataType : "JSON",
				success : function(result) {
					console.log(result);
					if(result.success){
						$("#saveOrEdit").val(0);
						$("#stuNumber").val(result.data.stuNumber);
						$("#stuNumber").attr("readOnly",true);
						$("#javaScore").val(result.data.javaScore);
						$("#cPlusScore").val(result.data.cplusScore);
						$("#mysqlScore").val(result.data.mysqlScore);
						$("#mathScore").val(result.data.mathScore);
						$("#chemistryScore").val(result.data.chemistryScore);
						$("#biologyScore").val(result.data.biologyScore);
						$("#historyScore").val(result.data.historyScore);
					}else{
						$("body").MessageBox({
							type: 'error',
							message:result.info,
							timeout:3000,
							callbak:null
						});
						alert(result.info)
					}
				}
			});
		}

		//删除提示框
		function confrimRemove(id){
			$("#remove-dialog").modal();
			$("#cacheID").val(id);
		}

		//删除确定
		function remove(){
			var stuNumber = $("#cacheID").val();
			window.location.href="/stu/score/delete?stuNumber="+stuNumber;
			$("#remove-dialog").modal('hide');
		}
	</script>
</body>
</html>
